﻿@model IEnumerable<CSCSN.ViewModels.ApplicationTaskVM>

@{
    Layout = null;

    // 提取控制器路径
    var controllerPath = "/" + ViewContext.RouteData.Values["controller"].ToString();

    // 新建或者编辑对象的路径
    var creatOrEditUrlString = controllerPath + "/CreateOrEdit/";
    // 根据关键词检索列表数据的路径
    var searchWithKeywordUrlString = controllerPath + "/List?keyword=";
    // 明细数据路径
    var detailUrlString = controllerPath + "/Detail/";
    // 删除数据路径
    var deleteUrlString = controllerPath + "/Delete/";
    // 缺省的列表页路径
    var defaultListUrlString = controllerPath + "/TaskQueryList/";
    // 用户添加任务路径
    var userAddTaskListUrlString = controllerPath + "/UserAddTask/";
    // 用户取消任务路径搜索结果
    var userCancelTaskListUrlString = controllerPath + "/UserCancelTask/";

    var pageGroup = ViewData["PageGroup"] as CSCSN.DataAccess.Tool.PagenateGroup;
    var allTaskSites = ViewData["AllTaskSites"] as List<CSCSN.EntitiyModels.ApplicationTaskAbout.TaskSite>;
    var alIssuers = ViewData["AllIssuers"] as List<CSCSN.EntitiyModels.ApplicationRole>;
    var allTaskType = ViewData["AllTaskType"] as List<CSCSN.EntitiyModels.ApplicationTaskType>;

}
<head>
    <link href="~/css/icon.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/site.css" />
    <link href="~/css/Login.css" rel="stylesheet" />
    <link href="~/css/lunbo.css" rel="stylesheet" />
    <link href="~/css/headmemu.css" rel="stylesheet" />

    <style>
        a p {
            color: black;
        }

        input[type="radio"] {
            display: none;
        }

        .Radio + .radio {
            padding: 0.2em 1em;
            border: 2px solid #CCCCCC;
            color: #999;
            text-align: center;
        }


        .Radio:checked + .radio {
            padding: 0.2em 1em;
            border: 2px solid #3399CC;
            text-align: center;
            background: #3399CC;
            color: #FFFFFF;
        }
        .conditionSex {
            /* height: 99%;
            width: 100%;
            overflow: auto;
            background: #EEEEEE;*/
            /*position: fixed;*/
            height: 99%;
            overflow: auto;
            float: left;
        }
        
    </style>
</head>

<body>
    <div class="container-fluid">
        <div class="row">
            <!-- 条件选择区 -->
            <div class="col-md-4 ">
                <div class="conditionSex">
                    <div class="search-wrap">

                        <input type="search" id="keyWord" name="keyWord" class="search-keyword" value="@ViewBag.keyWord">
                        <button type="button" class="search-submit" onclick="clickConditionRadio()">
                            <i class="iconfont "></i>
                        </button>

                    </div>
                    <a class="page-link" href="javascript:filterConditionShowOrNone('taskSiteCondition')">
                        <p>地点</p>
                        <div id="taskSiteCondition" style="display:none">
                            <br />
                            @{
                                <input id="taskSite 0" class="Radio" type="radio" name="taskSite" placeholder="" value="0" checked onclick="clickConditionRadio()" /><label for="taskSite 0" class="radio">不限</label>
                                int i = 0;
                                foreach (var item in allTaskSites)
                                {
                                    i++;
                                    <input id="taskSite @i" class="Radio" type="radio" name="taskSite" placeholder="" value=@item.Id onclick="clickConditionRadio()" /><label for="taskSite @i" class="radio">@item.Name </label>
                                }
                            }
                        </div>
                    </a>

                    <a class="page-link" href="javascript:filterConditionShowOrNone('taskTypeCondition')">
                        <p>类型</p>
                        <div id="taskTypeCondition" style="display:none">
                            <br />
                            @{
                                <input id="taskType 0" class="Radio" type="radio" name="taskType" placeholder="" value="0" checked onclick="clickTypeChangeScore('不限'),clickConditionRadio()" /><label for="taskType 0" class="radio">不限</label>
                                int k = 0;
                                foreach (var item in allTaskType)
                                {
                                    k++;
                                    <input id="taskType @k" class="Radio" type="radio" name="taskType" placeholder="" value="@item.Id" onclick="clickTypeChangeScore('@item.Name'),clickConditionRadio()" /><label for="taskType @k" class="radio">@item.Name</label>
                                }
                            }
                            <br />
                            @*分值*@
                            <div id="score"></div>


                        </div>
                    </a>


                    <a class="page-link" href="javascript:filterConditionShowOrNone('issuerCondition')">
                        <p>发起人</p>
                        <div id="issuerCondition" style="display:none">
                            <br />
                            @{
                                <input id="issuer 0" class="Radio" type="radio" name="issuer" placeholder="" value="0" checked onclick="clickConditionRadio()" /><label for="issuer 0" class="radio">不限</label>
                                int j = 0;
                                foreach (var item in alIssuers)
                                {
                                    j++;
                                    <input id="issuer @j" class="Radio" type="radio" name="issuer" placeholder="" value=@item.Id onclick="clickConditionRadio()" /><label for="issuer @j" class="radio">@item.Name </label>
                                }
                            }
                        </div>
                    </a>


                    <a class="page-link" href="javascript:filterConditionShowOrNone('beginTimeCondition')">
                        <p>开始时间</p>
                        <div id="beginTimeCondition" style="display:none">
                            <br />
                            <input id="beginTime 0" class="Radio" type="radio" name="beginTime" placeholder="" value="不限" checked onclick="clickConditionRadio()" /><label for="beginTime 0" class="radio">不限</label>
                            <input id="beginTime 1" class="Radio" type="radio" name="beginTime" placeholder="" value="今天" onclick="clickConditionRadio()" /><label for="beginTime 1" class="radio">今天</label>
                            <input id="beginTime 2" class="Radio" type="radio" name="beginTime" placeholder="" value="明天" onclick="clickConditionRadio()" /><label for="beginTime 2" class="radio">明天</label>
                            <input id="beginTime 3" class="Radio" type="radio" name="beginTime" placeholder="" value="后天+" onclick="clickConditionRadio()" /><label for="beginTime 3" class="radio">后天+</label>
                        </div>
                    </a>

                    <a class="page-link" href="javascript:filterConditionShowOrNone('durationCondition')">
                        <p>时长</p>
                        <div id="durationCondition" style="display:none">
                            <br />
                            <input id="duration 0" class="Radio" type="radio" name="duration" placeholder="" value="不限" checked onclick="clickConditionRadio()" /><label for="duration 0" class="radio">不限</label>
                            <input id="duration 1" class="Radio" type="radio" name="duration" placeholder="" value="1-3" onclick="clickConditionRadio()" /><label for="duration 1" class="radio">1-3小时</label>
                            <input id="duration 2" class="Radio" type="radio" name="duration" placeholder="" value="3-5" onclick="clickConditionRadio()" /><label for="duration 2" class="radio">3-5小时</label>
                            <input id="duration 3" class="Radio" type="radio" name="duration" placeholder="" value="5以上" onclick="clickConditionRadio()" /><label for="duration 3" class="radio">5小时以上</label>
                        </div>
                    </a>
                </div>
            </div>

            <!-- 主工作区 -->
            <div id="mainWorkPlaceArea" class="col-md-8">
                <partial name="TaskQueryList" model="@Model" />
                <a href="@Url.Action("Index","Home")">回到首页</a>
            </div>

        </div>

        <!-- 用于处理添加任务提醒以及返回添加错误信息的模态对话框 -->
        <div class="modal fade" id="userAddTaskItemModal" tabindex="-1" role="dialog" aria-labelledby="userAddTaskItemModal" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3 class="modal-title" id="exampleModalLongTitle"></h3>
                    </div>
                    <div class="modal-body" id="" style="color:red">
                        <p id="userAddTaskModalMessage" style="color:red"></p>                            <!--这是一个空的文字段落标签，用于显示所需要的提示信息-->
                        <p id="userAddTaskModalErrMessage" style="color:red"></p>                         <!--这是一个空的文字段落标签，用于显示数据操作是否成功-->

                        <input type="hidden" name="businessObjectID" id="businessObjectID" />        <!--这个标签用于转移待添加任务的ID-->
                        <input type="hidden" name="controllerName" id="controllerName" />            <!--这个标签用于转移待添加任务的控制器名称-->
                        <input type="hidden" name="userAddTaskUrlString" id="userAddTaskUrlString" /><!--这个标签用于转移待添加任务的提交的路径-->
                        <input type="hidden" name="defaultUrlString" id="defaultUrlString" value="@defaultListUrlString" />        <!--这个标签用于转移待添加任务成功后返回的路径-->
                        <input type="hidden" name="mainWorkPlaceAreaId" id="mainWorkPlaceAreaId" value="mainWorkPlaceArea" />                 <!--这个标签用于转移显示返回数据 UI 的 div 标识-->
                        <input type="hidden" name="pageIndex" id="pageIndex" value="@pageGroup.PageIndex"/>                      <!--这个标签用于转移当前数据位于的页数-->
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                        <!-- 这个按钮执行的方法在 appFunctionForCommon.js 中实现，作用是提取渲染这个页面时所创建的上面 5 个 input 标签元素的值，提交到删除的 action 处理，成功则跳转回缺省列表页 -->
                        <button type="button" class="btn btn-danger" onclick="appGotoUserAddTaskPaginateBoForS()">确认</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

<!-- 单击条件选项后，就刷新页面-->
<script>

    function clickConditionRadio() {
        var urlString = $341('#defaultUrlString').val();
        var mainWorkPlaceAreaId = $341('#mainWorkPlaceAreaId').val();
        var pageIndex = $341('#pageIndex').val();
        appGotoDefaultPaginatePageForS(pageIndex, urlString, mainWorkPlaceAreaId);

    }
</script>

<!-- 实现类型不同，分值不同-->
<script>

    function clickTypeChangeScore(taskTypeName) {

        var date = "";
        if (taskTypeName == '诚信分') {
            var all_score = ["20-60", "60-100", "100以上"]
            date = "<p>分值</p> <br /><input id=\"score 0\" class=\"Radio\" type=\"radio\" name=\"score\" placeholder=\"\" value=\"0\" checked=\"\" onclick=\"clickConditionRadio()\" ><label for=\"score 0\" class=\"radio\">不限</label>";
            for (var i = 0; i < 3; i++) {
                date = date + "<input id=\"score" + i + 1 + "\" class=\"Radio\" type=\"radio\" name=\"score\" placeholder=\"\" value=\"" + all_score[i] + "\"onclick=\"clickConditionRadio()\"><label for=\"score" + i + 1 + "\" class=\"radio\">" + all_score[i] + "诚信分" + "</label > ";
            }
        }
        if (taskTypeName == '义工时') {
            var all_score = ["1-5", "5-9", "9以上"]
            date = "<p>分值</p> <br /><input id=\"score 0\" class=\"Radio\" type=\"radio\" name=\"score\" placeholder=\"\" value=\"0\" checked=\"\" onclick=\"clickConditionRadio()\"><label for=\"score 0\" class=\"radio\">不限</label>";
            for (var i = 0; i < 3; i++) {
                date = date + "<input id=\"score" + i + 1 + "\" class=\"Radio\" type=\"radio\" name=\"score\" placeholder=\"\" value=\"" + all_score[i] + "\" onclick=\"clickConditionRadio()\"><label for=\"score" + i + 1 + "\" class=\"radio\">" + all_score[i] + "义工时" + "</label > ";
            }
        }
        if (taskTypeName == '活动分') {
            var all_score = ["1-5", "5-9", "9以上"]
            date = "<p>分值</p><br /><input id=\"score 0\" class=\"Radio\" type=\"radio\" name=\"score\" placeholder=\"\" value=\"0\" checked=\"\" onclick=\"clickConditionRadio()\"><label for=\"score 0\" class=\"radio\">不限</label>";
            for (var i = 0; i < 3; i++) {
                date = date + "<input id=\"score" + i + 1 + "\" class=\"Radio\" type=\"radio\" name=\"score\" placeholder=\"\" value=\"" + all_score[i] + "\" onclick=\"clickConditionRadio()\"><label for=\"score" + i + 1 + "\" class=\"radio\">" + all_score[i] + "活动分" + "</label > ";
            }
        }
        if (taskTypeName == '不限') {
            date = "";
        }
        document.getElementById("score").innerHTML = date;

    }
</script>

<!-- 实现筛选条件的显示与隐藏-->
<script>
    function filterConditionShowOrNone(conditionId) {
        var displayState = document.getElementById(conditionId).style.display;
        if (displayState == 'block') {
            document.getElementById(conditionId).style.display = 'none'
        }
        else {
            document.getElementById(conditionId).style.display = 'block'
        }
    }
</script>

<!-- 创建任务筛选器的JSON字符串-->
<script>
    /**
    * 提取页面规格数据,构建 TaskQueryJson 对象
    *  以字符串方式构成的 TaskQueryJson 参数
    */
    function appGetListSinglePageParameterJson() {
        // 提取缺省的页面规格参数
        var keyWord = $341('#keyWord').val();
        var taskSite = $341('#taskSiteCondition input[name="taskSite"]:checked ').val();
        var taskType = $341('#taskTypeCondition input[name="taskType"]:checked ').val();
        var score = $341('#score input[name="score"]:checked ').val();
        var issuer = $341('#issuerCondition input[name="issuer"]:checked ').val();
        var beginTime = $341('#beginTimeCondition input[name="beginTime"]:checked ').val();
        var duration = $341('#durationCondition input[name="duration"]:checked ').val();
        // 创建前端 json 数据对象
        var taskQueryJson = "{" +
            "KeyWord:\"" + keyWord + "\", " +
            "TaskSite:\"" + taskSite + "\", " +
            "TaskType:\"" + taskType + "\", " +
            "Score:\"" + score + "\", " +
            "Issuer:\"" + issuer + "\", " +
            "BeginTime:\"" + beginTime + "\", " +
            "Duration:\"" + duration + "\"," +
            "}";
        return taskQueryJson;
    }
</script>

<!-- 实现用户添加、取消任务-->
<script>

    /**
 * 打开添加任务的提示对话框
 *  modalId 待打开的会话模态框的 id
 * itemId 待添加的数据元素的 Id
 *  message 提示信息
 *  creatUrlString 后端执行添加操作的 Url
 *  defaultUrlString 执行添加操作以后，返回的缺省页面对应的 action 路径
 * mainWorkPlaceAreaId 主显示区 div 的 id
 */

    function appOpenUserAddTaskItemModalForS(action, modalId, itemId, message, userAddTaskListUrlString, defaultUrlString, mainWorkPlaceAreaId, pageIndex) {
        $341('#' + modalId).modal({
            show: true,
            backdrop: 'static'
        });
        document.getElementById("userAddTaskModalMessage").innerHTML = message;
        document.getElementById("exampleModalLongTitle").innerHTML = action;
        $341('#businessObjectID').val(itemId);
        $341('#userAddTaskUrlString').val(userAddTaskListUrlString);
        $341('#defaultUrlString').val(defaultUrlString);
        $341('#mainWorkPlaceAreaId').val(mainWorkPlaceAreaId);
        $341('#pageIndex').val(pageIndex);
        document.getElementById("userAddTaskModalErrMessage").innerText = '';
    }



    /*
     * 对于列表元素执行实际的操作
     */
    function appGotoUserAddTaskPaginateBoForS() {
        var boVMID = $341('#businessObjectID').val();
        var userAddTaskUrl = $341('#userAddTaskUrlString').val();
        var urlString = $341('#defaultUrlString').val();
        var mainWorkPlaceAreaId = $341('#mainWorkPlaceAreaId').val();
        var pageIndex = $341('#pageIndex').val();
        $341.ajax({
            cache: false,
            type: 'get',
            async: true,
            url: userAddTaskUrl + boVMID,
            beforeSend: function () {
            }
        }).done(function (delStatus) {
            if (delStatus === true) {
                $341('#userAddTaskItemModal').modal('hide');
                // 刷新列表页
                appGotoDefaultPaginatePageForS(pageIndex, urlString, mainWorkPlaceAreaId);
            } else {
                document.getElementById("userAddTaskModalErrMessage").innerText = '请勿重复添加任务';
            }
        }).fail(function () {
            alert("请您登录后操作！");
            window.location.href = "/Account/Login";
        }).always(function () {
        });
    }





</script>

<!-- 局部刷新页面-->
<script>
    /*
*局部刷新页面实现
 * pageIndex 当前页码
*  urlString 后台 action 路径
*  mainWorkPlaceAreaId 主显示区域 Div 的 id
*/
    function appGotoDefaultPaginatePageForS(pageIndex, urlString, mainWorkPlaceAreaId) {
        var listParaJson = appGetListSinglePageParameterJson();
        var jsonData = { "listPageParaJson": listParaJson };
        $341.ajax({
            cache: false,
            type: "get",
            async: true,
            url: urlString,
            data: { "pageIndex": pageIndex, "taskQueryJson": listParaJson },
            beforeSend: function () {
                document.getElementById(mainWorkPlaceAreaId).innerHTML = "<p style='margin-top:80px;' align='center'> <i class='fa fa-spinner fa-pulse fa-2x'></i></p>" +
                    "<p style='margin-top:20px;' align='center'>  数据加载中，请稍候...</p>";
            }
        }).done(function (data) {
            document.getElementById(mainWorkPlaceAreaId).innerHTML = data;
            //resetDivHeight();
            //appinitialCommonListContainer();
            //initialPurchaserCommoditySearchList();

        }).fail(function (jqXHR, textStatus, errorThrown) {
            // 调试时候观察错误
            console.error("调试错误:" + errorThrown);
        }).always(function () {
        });
    }
</script>

<!-- 引入 jquery 1.10.2 -->
<script src="~/lib/jquery/dist/jquery-1.10.2.js"></script>
<script type="text/javascript">
    var $1102 = jQuery.noConflict();
</script>

<!-- 引入 jquery 3.4.1 -->
<script src="~/lib/jquery/dist/jquery-3.4.1.js"></script>
<script type="text/javascript">
    var $341 = jQuery.noConflict();
</script>
<script src="/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
